package org.example.hansp.recursion;

public class MonkeyEat {
    public static void main(String[] args) {
        int total = monkeyEatPeach(10);
        System.out.println(total);
        int total2 = monkeyEatPeach2(1);
        System.out.println(total2);
    }

    public static int monkeyEatPeach(int n) {
     /*   if(n>1){
            return (monkeyEat(n-1)+1)*2;
        }else {
            return 1;
        }
    }*/
        if (n == 1) {
            return 1;
        } else {
            return (monkeyEatPeach(n - 1) + 1) * 2;
        }
    }

    public static int monkeyEatPeach2(int day) {
        if(day==10){
            return 1;
        }else if(day>=1&&day<=9){
            return (monkeyEatPeach2(day+1)+1)*2;
        }else {

            return day;
        }
    }
}
